package cn.ihna.demo.algorithm.graph;

/**
 * @author xianyingda@gmail.com
 * @serial
 * @since 2020-08-29 17:24
 */
public class DenseGraph {
    private int n, m; // 点数和边数
    private boolean directed;
    private boolean[][] g;

    public DenseGraph(int n, boolean directed) {
        this.n = n;
        this.m = 0;
        this.directed = directed;
        this.g = new boolean[n][n];
    }

    public int v() {
        return n;
    }

    public int e() {
        return m;
    }

    void addEdge(int v, int w) {
        if (v < 0 || w < 0 || v >= n || w >= n) {
            throw new RuntimeException("out of bound");
        }
        g[v][w] = true;
        if (!directed) {
            g[w][v] = true;
        }
    }
}
